﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Nirvana
{
    /// <summary>
    /// 场景采集点配置脚本
    /// </summary>
	public class SceneGatherPoint : SceneObject
	{
#if UNITY_EDITOR
        [SerializeField]
        [Header("gather.xml表ID")]
        private int gatherID;

        [SerializeField]
        [Tooltip("The index of this gather point.")]
        private int index;

        [SerializeField]
        [Header("采集点生成间隔(ms)")]
        private int interval = 4000;

        [SerializeField]
        [Header("采集需要时间(ms)")]
        private int gatherTime = 2000;

        [SerializeField]
        [Tooltip("The time to disappear after gathered.")]
        private int disappearAfterGather = 0;

        [SerializeField]
        [Tooltip("evil add.")]
        private int evilAdd = 0;

        [Header("预览对象资源")]
        [SerializeField]
        private AssetID previewAssetId;
        // The preview prefab.
        private GameObject previewPrefab;

        public int ID {get { return this.gatherID; }}
        public int Index { get { return this.index; } }
        public int Interval { get { return this.interval; } }
        public int GatherTime { get { return this.gatherTime; } }
        public int DisappearAfterGather { get { return this.disappearAfterGather; } }
        public int EvilAdd { get { return this.evilAdd; } }

        protected override bool HasPreview()
        {
            return this.previewPrefab != null;
        }

        protected override GameObject BuildPreview()
        {
            return Instantiate(this.previewPrefab);
        }


        void OnValidate()
        {
            if (Application.isPlaying) return;
            this.name = "Gather" + this.gatherID;
            if (!string.IsNullOrEmpty(previewAssetId.AssetGUID))
            {
                this.previewPrefab = previewAssetId.LoadObject<GameObject>();
            }
            else
            {
                //Debug.LogWarning("Can not find NPC with id: " + this.npcId);
                this.previewPrefab = null;
            }
            this.RefreshPreview();
        }


#endif

    }
}

